class getPara {
    static getQueryString(name, search) {
        search = search || window.location.search.substr(1);
        let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        let r = search.match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }

    static getHashString(name) {
        let search = window.location.hash;
        let reg = new RegExp("(^|&|#)" + name + "=([^&]*)(&|$)");
        let r = search.match(reg);
        if (r != null) return unescape(r[2]);
        return "";
    }

    static basename(str) {
        let idx = str.lastIndexOf('/')
        idx = idx > -1 ? idx : str.lastIndexOf('\\')
        if (idx < 0) {
            return str
        }
        return str.substring(idx + 1);
    }

    static parse_koji_url(str) {
        let reg = new RegExp("^(?:http(s)?:\\/\\/)\\w+.\\w+.\\w+.(\\d+)/koji/taskinfo\\?taskID=(\\d+)$");
        let res = str.match(reg)
        if (res) return res;
        return []
    }
}

export default getPara;
